
module lhd {
    export class PlayMediatorLHD extends BaseMediator {
        public static NAME: string = "PlayMediatorLHD";

        public constructor(viewComponent: any = null) {
            super(PlayMediatorLHD.NAME, viewComponent);
        }
        public listNotificationInterests(): Array<any> {
            return [
                PanelNotify.HALL.STAGE_RESIZE,
                PanelNotify.LHD.CLOSE_PLAY_GAME,
                PanelNotify.LHD.JOIN_ROOM,
                PanelNotify.LHD.START_GAME,
                PanelNotify.LHD.FREE_GAME,
                PanelNotify.LHD.BET_RECEIVE,
                PanelNotify.LHD.GAME_OVER,
                PanelNotify.LHD.GAME_LUDAN,
                PanelNotify.LHD.DATA_RECOVERY,
                PanelNotify.LHD.GET_SERIAL_NUMBER,
                PanelNotify.LHD.RECEIVE_USER_LIST

            ]
        }

        private timeOutArr = [];
        public playPanel: PlayPanelLHD;//基础面板
        private globLook: boolean = false;//结算过程金额不准变动
        private scollzhupan = 0;
        private bScollzhupan = 0;
        private bet_chip = [100, 1000, 5000, 10000, 50000];//筹码规格
        private betImgArr: Array<Array<eui.Image>> = [[], [], [], [], [], []];//6个筹码区域的图片都放在这个数组，结算动画匹配5个输家数组种图片飞向庄家，庄家赔钱飞向赢家数组
        private pokerXY = [[{ x: 505.5, y: 0.3 }], [{ x: 780.98, y: 0.3 }]];//所有扑克牌在UI中的坐标，发牌动画时用到
        /**
         * 下注区域对应后端值
         * cmd.AREA_XIAN = 0 --闲家索引
cmd.AREA_PING = 1 --平家索引
cmd.AREA_ZHUANG = 2 --庄家索引
cmd.AREA_XIAN_TIAN = 3 --闲天王
cmd.AREA_ZHUANG_TIAN = 4 --庄天王
cmd.AREA_TONG_DUI = 5 --同点平
cmd.AREA_XIAN_DUI = 6 --闲对子
cmd.AREA_ZHUANG_DUI = 7 --庄对子
cmd.AREA_XINGYUN = 8 --幸运6
cmd.AREA_MAX = 9 --最大区域
         */
        public handleNotification(notification: puremvc.INotification): void {
            switch (notification.getName()) {
                case PanelNotify.HALL.STAGE_RESIZE:
                    if (this.playPanel) {
                        this.playPanel.width = GameConfig.curWidth()
                        this.playPanel.height = GameConfig.curHeight()
                    }
                    break;
                case PanelNotify.LHD.CLOSE_PLAY_GAME:
                    this.destroy();
                    break;
                case PanelNotify.LHD.JOIN_ROOM:
                    if (this.playPanel && this.playPanel.parent) {
                        this.initUserInfo();
                    } else {//游戏中途加入有可能 先进玩家后加载房间数据，这时候面板还没起来。后台BUG
                        this.playPanel = null;
                        this.playPanel = new PlayPanelLHD();
                        this.showUI(this.playPanel, 2, 5);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.JOIN_GAME_BY_HALL)
                    }
                    break;
                case PanelNotify.LHD.GET_SERIAL_NUMBER:
                    this.initRoomInfo();
                    break;
                case PanelNotify.LHD.START_GAME:
                    this.gameStart()
                    break;
                case PanelNotify.LHD.FREE_GAME:
                    this.gameFree()
                    break;
                case PanelNotify.LHD.BET_RECEIVE:
                    this.betReceive()
                    break;
                case PanelNotify.LHD.DATA_RECOVERY:
                    this.dataRecovery();
                    break;
                case PanelNotify.LHD.GAME_OVER:
                    this.gameOver()
                    break;
                case PanelNotify.LHD.GAME_LUDAN:
                    let ifLast = false;
                    this.ludanShow(ifLast, 0)
                    break;
                case PanelNotify.LHD.RECEIVE_USER_LIST:
                    this.receiveUserList();
                    break;
            }
        }

        /**
         * 初始化面板ui
         */
        public initUI(): void {
            //切换音乐
            if (InstructionsEnum.SOUND_GAME != InstructionsEnum.GAME_SOUND_NAME.LHD) {
                SoundManage.stopYinYue();
                InstructionsEnum.SOUND_GAME = InstructionsEnum.GAME_SOUND_NAME.LHD;
                SoundManage.startYinYueLoad();
            }
            //将滚动公告转移到当前面板
            EffectUtils.moveNoticeToPanel(this.playPanel.noticeGroup)


            this.playPanel.bet_button_bg_1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRectClick, this)
            this.playPanel.bet_button_bg_3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRectClick, this)
            this.playPanel.bet_button_bg_5.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRectClick, this)
            this.playPanel.bet_button_group.addEventListener(egret.TouchEvent.TOUCH_TAP, this.betGroupClick, this)

            this.playPanel.dalu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
            this.playPanel.zhupan_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)

            this.playPanel.menu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.menu_click, this)
            this.playPanel.menu_fankui.addEventListener(egret.TouchEvent.TOUCH_TAP, this.fankuiClick, this)
            this.playPanel.menu_jilu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.jiluClick, this)
            this.playPanel.menu_set.addEventListener(egret.TouchEvent.TOUCH_TAP, this.setClick, this)
            this.playPanel.menu_help.addEventListener(egret.TouchEvent.TOUCH_TAP, this.helpClick, this)
            this.playPanel.menu_exit.addEventListener(egret.TouchEvent.TOUCH_TAP, this.exitClick, this)
            this.playPanel.otherUserImg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.userListClic, this)

        }
        /**
         * 初始化面板数据
         */
        public initData(): void {
            InstructionsEnum.isHall = true;
            this.globLook = false;
            this.clearData();
            this.initUserInfo();
        }
        //初始化页面数据
        private clearData() {
            this.globLook = false
            this.playPanel.bet_num_1.text = "";
            this.playPanel.bet_num_3.text = "";
            this.playPanel.bet_num_5.text = "";

            this.playPanel.my_bet_num_1.text = "";
            this.playPanel.my_bet_num_3.text = "";
            this.playPanel.my_bet_num_5.text = "";
            // this.playPanel.my_betNum.text = "";
            // this.playPanel.ludan_group.visible = true;
            this.playPanel.poker_group.visible = false;
            this.playPanel.win_img.source = ""
            for (let i = 0; i < 1; i++) {
                this.playPanel["poker_xian_" + i].x = 1130
                this.playPanel["poker_xian_" + i].y = 100
                this.playPanel["poker_xian_" + i].source = "ddz_poker_back"
                this.playPanel["poker_xian_" + i].rotation = 310
                this.playPanel["poker_xian_" + i].scaleX = 0.2
                this.playPanel["poker_xian_" + i].scaleY = 0.2
                this.playPanel["poker_xian_" + i].visible = false
            }
            for (let i = 0; i < 1; i++) {
                this.playPanel["poker_zhuang_" + i].x = 1130
                this.playPanel["poker_zhuang_" + i].y = 100
                this.playPanel["poker_zhuang_" + i].source = "ddz_poker_back"
                this.playPanel["poker_zhuang_" + i].rotation = 310
                this.playPanel["poker_zhuang_" + i].scaleX = 0.2
                this.playPanel["poker_zhuang_" + i].scaleY = 0.2
                this.playPanel["poker_zhuang_" + i].visible = false
            }
            this.playPanel.timeOut.destroy()
            this.playPanel.xiazhu_tips.visible = false;
            this.betImgArr = [[], [], [], [], [], []];

            this.playPanel.bet_img_group.removeChildren();
            this.playPanel.title.visible = false;
            this.playPanel.score_user.text = "";
            this.playPanel.title.x = -(this.playPanel.title.width);
            this.IsUserScore(0)
        }
        //销毁UI
        public destroy(): void {
            InstructionsEnum.isHall = false;
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.CLOSE_HELP);
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.CLOSE_USER_LIST);
            this.closePanel(1);
        }
        //玩家信息
        private initUserInfo() {
            //玩家信息
            this.playPanel.userName.text = Global.cutString(GameVO.getVo().szNickName);
            this.playPanel.userImg.source = "special_" + GameVO.getVo().wFaceID;
            if (LhdVO.getVo().structUserList) {
                this.playPanel.otherUserNum.text = LhdVO.getVo().structUserList.length + ""
            } if (this.globLook == false) {
                this.playPanel.userMoney.text = LhdVO.getVo().lUserScore / 100 + "";
            }
        }
        //房间信息
        private initRoomInfo() {
            this.playPanel.bianhao.text = "局号：" + LhdVO.getVo().gameNumbering;
            this.playPanel.bet_num_1.text = "" + LhdVO.getVo().betNumAdds_1 / 100;
            this.playPanel.bet_num_3.text = "" + LhdVO.getVo().betNumAdds_3 / 100;
            this.playPanel.bet_num_5.text = "" + LhdVO.getVo().betNumAdds_5 / 100;
        }
        //游戏开始
        private gameStart() {
            var thisBack = this;
            thisBack.clearData();
            thisBack.playPanel.title.source = "wjl_ksxz"
            thisBack.playPanel.title.visible = true;
            this.playPanel.bet_button_bg_1.visible = true;
            this.playPanel.bet_button_bg_3.visible = true;
            this.playPanel.bet_button_bg_5.visible = true;
            EffectUtils.Twinkle(this.playPanel.bet_button_bg_1, 3, 200)
            EffectUtils.Twinkle(this.playPanel.bet_button_bg_3, 3, 200)
            EffectUtils.Twinkle(this.playPanel.bet_button_bg_5, 3, 200)
            egret.Tween.get(thisBack.playPanel.title).to({ x: GameConfig.curWidth() / 2 - thisBack.playPanel.title.width / 2 }, 261).wait(500).to({ x: GameConfig.curWidth() }, 261.68).call(() => {
                thisBack.playPanel.title.visible = false;
                thisBack.playPanel.title.x = -(this.playPanel.title.width);
                thisBack.IsUserScore(LhdVO.getVo().lUserScore, false, true)
                thisBack.playPanel.xiazhu_tips.source = "lhd_xiazhu"
                thisBack.playPanel.xiazhu_tips.visible = true;
                thisBack.playPanel.timeOut.init(9, true)
                SoundManage.startYinxiaoLoad("lhd_gameStart_mp3");
            })
            if (LhdVO.getVo().gameNum >= 6) {
                let data = {
                    wTableID: LhdVO.getVo().wTableId,
                    wChairID: LhdVO.getVo().wChairId,
                    cbForceLeave: 1
                }
                SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.LHD, RegDataGamePublic.CMD_GP_LeaveGame, data, true);
                Global.tipShow("您已经连续 5 局未下注，被请离了游戏桌")
            } else if (LhdVO.getVo().gameNum == 4) {
                Global.tipShow("您已经连续 3 局未下注，连续 5 局未下注将被请离游戏桌!")
            }
        }
        //游戏空闲
        private gameFree() {
            var thisBack = this;
            if (LhdVO.getVo().status == 0) {
                thisBack.playPanel.xiazhu_tips.source = "lhd_xiuxi"
                thisBack.playPanel.score_user.visible = false
            }
            else {
                thisBack.playPanel.xiazhu_tips.source = "lhd_dengdai"
            }
            thisBack.playPanel.xiazhu_tips.visible = true;
            thisBack.playPanel.timeOut.init(LhdVO.getVo().cbTimeLeave, true)
            thisBack.playPanel.bet_button_bg_1.visible = false;
            thisBack.playPanel.bet_button_bg_3.visible = false;
            thisBack.playPanel.bet_button_bg_5.visible = false;
            this.playPanel.bipai_group.visible = false;
            this.playPanel.poker_group.visible = false;

        }
        //下注返回
        private betReceive() {
            this.playPanel.my_bet_num_1.text = '/' + LhdVO.getVo().myBetNumAdds_1 / 100 + '';
            this.playPanel.my_bet_num_3.text = '/' + LhdVO.getVo().myBetNumAdds_3 / 100 + '';
            this.playPanel.my_bet_num_5.text = '/' + LhdVO.getVo().myBetNumAdds_5 / 100 + '';
            let startX, startY, endX, endY, width, heigth, arr: Array<eui.Image>;//筹码飞行动画起始位置，结束位置,结束区域宽高,装筹码的数组
            let betUser = LhdVO.getVo().betUser;
            let betAdds = LhdVO.getVo().betAdds;
            let betNum = LhdVO.getVo().betNum;
            let isMy = false;
            if (betUser == LhdVO.getVo().wChairId) {
                this.playPanel.userMoney.text = LhdVO.getVo().lUserScore / 100 + "";
                this.IsUserScore(LhdVO.getVo().lUserScore, true)
                startX = this.playPanel.userInfo.x + 60 - this.playPanel.bet_img_group.x
                startY = this.playPanel.userInfo.y - 25 - this.playPanel.bet_img_group.y;
                isMy = true;
            } else {
                startX = this.playPanel.otherUserImg.x + 25 - this.playPanel.bet_img_group.x;
                startY = this.playPanel.otherUserImg.y + 25 - this.playPanel.bet_img_group.y;
            }
            switch (betAdds) {
                case 2://和
                    endX = 287
                    endY = 395
                    width = 804
                    heigth = 80
                    arr = this.betImgArr[1];
                    LhdVO.getVo().betNumAdds_1 += betNum
                    break;
                case 0://龙
                    endX = 267
                    endY = 197
                    width = 288
                    heigth = 100
                    arr = this.betImgArr[3];
                    LhdVO.getVo().betNumAdds_3 += betNum
                    break;
                case 1://虎
                    endX = 795
                    endY = 197
                    width = 288
                    heigth = 100
                    arr = this.betImgArr[5];
                    LhdVO.getVo().betNumAdds_5 += betNum
                    break;
            }
            let imgArr = this.qiegeJinbi(betNum);
            for (let y = 0; y < imgArr.length; y++) {
                let img = betImgPool.getFreeObject("bet_" + (imgArr[y] / 100));
                img.x = startX;
                img.y = startY;
                img.width = 50;
                img.height = 50;
                img.visible = false;
                img.name = betUser + "";//记住是谁下的注，庄家赔钱时这个注要飞向下注那个玩家
                this.playPanel.bet_img_group.addChild(img);
                arr.push(img)
                egret.Tween.get(img).wait(isMy ? 0 : this.random_num(50, 700)).to({ visible: true }).to({ x: endX + width * Math.random(), y: endY + heigth * Math.random() }, 500, egret.Ease.circInOut).call((img: eui.Image) => {
                    egret.Tween.removeTweens(img);
                }, this, [img]);
                if (Math.random() < 0.2) {//筹码太多,声音随机次数播放,降低性能消耗
                    let t = egret.setTimeout(() => {
                        SoundManage.startYinxiaoLoad("lhd_add_bet_mp3");
                        egret.clearTimeout(t)
                    }, this, this.random_num(10, 800))
                }
            }
            this.initRoomInfo();
        }

        private selectLudan: eui.Button = null;
        private ludanClick(event: egret.TouchEvent): void {
            this.selectLudan = event.currentTarget;
            if (this.selectLudan == this.playPanel.quanx_button) {
                this.ludanShow(false, 0)
                this.playPanel.quanlu_group.visible = true;
                this.playPanel.quanx_button.enabled = false;
                this.playPanel.quanx_button.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.dalu_group.visible = false;
                this.playPanel.dalu_button.enabled = true;
                this.playPanel.dalu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.zhupan_group.visible = false;
                this.playPanel.zhupan_button.enabled = true;
                this.playPanel.zhupan_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
            }
            if (this.selectLudan == this.playPanel.zhupan_button) {
                this.ludanShow(false, 2)
                this.playPanel.zhupan_group.visible = true;
                this.playPanel.zhupan_button.enabled = false;
                this.playPanel.zhupan_button.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.dalu_group.visible = false;
                this.playPanel.dalu_button.enabled = true;
                this.playPanel.dalu_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.quanlu_group.visible = false;
                this.playPanel.quanx_button.enabled = true;
                this.playPanel.quanx_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
            } if (this.selectLudan == this.playPanel.dalu_button) {
                this.ludanShow(false, 1)
                this.playPanel.dalu_group.visible = true;
                this.playPanel.dalu_button.enabled = false;
                this.playPanel.dalu_button.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.quanlu_group.visible = false;
                this.playPanel.quanx_button.enabled = true;
                this.playPanel.quanx_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)
                this.playPanel.zhupan_group.visible = false;
                this.playPanel.zhupan_button.enabled = true;
                this.playPanel.zhupan_button.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ludanClick, this)

            }
        }
        //路单
        private ludanShow(ifLast, btnCode) {
            if (btnCode == 0) {
                if (LhdVO.getVo().ludan.length == 0) {
                    for (let i = 0; i < this.playPanel.quanlu_dayanzai_scoll_group.numChildren; i++) {
                        if (this.playPanel.quanlu_dayanzai_scoll_group.getChildAt(i) instanceof eui.Image) {
                            betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_dayanzai_scoll_group.getChildAt(i))
                        }
                    }
                    this.playPanel.quanlu_dayanzai_scoll_group.removeChildren();
                    for (let i = 0; i < this.playPanel.quanlu_xiaolu_scoll_group.numChildren; i++) {
                        if (this.playPanel.quanlu_xiaolu_scoll_group.getChildAt(i) instanceof eui.Image) {
                            betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_xiaolu_scoll_group.getChildAt(i))
                        }
                    }
                    this.playPanel.quanlu_xiaolu_scoll_group.removeChildren();
                    for (let i = 0; i < this.playPanel.quanlu_yueyou_scoll_group.numChildren; i++) {
                        if (this.playPanel.quanlu_yueyou_scoll_group.getChildAt(i) instanceof eui.Image) {
                            betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_yueyou_scoll_group.getChildAt(i))
                        }
                    }
                    this.playPanel.quanlu_yueyou_scoll_group.removeChildren();
                }
                this.showDaYanZai(ifLast);
                this.showXiaoLu(ifLast);
                this.showJiaYouLu(ifLast);
            }
            let lieshu = 8
            let LuName = "quanlu_zhupanlu_scoll_group"
            let luZname = "scollzhupan"
            if (btnCode == 2) {
                lieshu = 32
                LuName = "zhupan_scoll_group"
            }
            let dlieshu = 8
            let dLuName = "quanlu_dalu_scoll_group"
            if (btnCode == 1) {
                dlieshu = 32
                dLuName = "dalu_scoll_group"
            }


            // //查询问路
            // //先模拟庄赢
            // var obj = {
            //     cbBankerCount: 2,
            //     cbPlayerCount: 1,
            //     bBankerTwoPair: false,
            //     bPlayerTwoPair: false,
            //     cbKingWinner: 0
            // }
            // LhdVO.getVo().ludan.unshift(obj);
            // var dayanzai_arr: Array<Array<Object>> = this.showDaYanZai(WjlVO.getVo().ludan, true);

            for (let i = 0; i < this.playPanel[LuName].numChildren; i++) {
                if (this.playPanel[LuName].getChildAt(i) instanceof eui.Image) {
                    betImgPool.returnObject(<eui.Image>this.playPanel[LuName].getChildAt(i))
                }
            }
            this.playPanel[LuName].removeChildren();
            for (let i = 0; i < this.playPanel[dLuName].numChildren; i++) {
                if (this.playPanel[dLuName].getChildAt(i) instanceof eui.Image) {
                    betImgPool.returnObject(<eui.Image>this.playPanel[dLuName].getChildAt(i))
                }
            }
            this.playPanel[dLuName].removeChildren();
            //溢出隐藏
            this.playPanel.quanlu_zhupanlu_group.scrollEnabled = true
            this.playPanel.quanlu_dalu_group.scrollEnabled = true
            this.playPanel.quanlu_dayanzai_group.scrollEnabled = true

            var arr = LhdVO.getVo().ludan;
            var leng = arr.length;
            var BankWinNum = 0//庄赢次数
            var PlayerWinNum = 0//闲赢次数
            var HeWinNum = 0//和赢次数
            //路单是否滚动
            if (Math.ceil(arr.length / 6) > lieshu) {
                this.playPanel[LuName].x = 0 - (Math.ceil(arr.length / 6) - lieshu) * 21
            }
            else {
                this.playPanel[LuName].x = 0
            }
            //大路
            // 大路是一个6行但列数很多的网格状图，记录时红圈代表庄赢，蓝圈代表闲赢。当赢家变为另一方时就要开始新的一列，所以大路会是红蓝圈交替的列。和局在大路中不使用单独的圈来显示，只有在上一手牌的圈上加一个数字，连续和局该数字累加
            //设计思路 把我们要生成的不管是蓝色还是红色还是文字，都按object的形式装进二维数组，，obj["zhuang"]=1 表示红色图片。obj["xian"]=1表示蓝色图片，obj["he"]=？表示有几次和局，之后遍历二维数组来生成视图，二维数组的两个下标作为XY坐标
            var List: Array<Array<Object>> = [[]];
            var hang = 0//竖坐标
            var lie = 0//横坐标
            var maxHang = 5;//1列最多6行，若第2列的第6行被第1列向右延申占领了，第2列就只能最大5行
            var upType = null//上一次是什么 0庄 1闲 2和
            //从数组指定位置获取对象，没有就创建
            var getObj = function (lie, hang): Object {
                if (List[lie] != null) {
                    if (List[lie][hang] != null) {
                        return List[lie][hang]
                    }
                }
                if (List[lie] == null) {
                    List[lie] = [];
                }
                if (List[lie][hang] == null) {
                    List[lie][hang] = {
                        zhuang: 0,
                        xian: 0,
                        he: 0,
                    }
                }
                return List[lie][hang]
            }
            var find = function (lie, hang): Boolean {
                if (List[lie] != null) {
                    if (List[lie][hang] != null) {
                        return true
                    }
                }
                return false;
            }

            for (let i = 0; i <= leng - 1; i++) {
                //全路
                var data = arr[i];
                var cbBankerCount = data["cbBankerCount"]
                var cbPlayerCount = data["cbPlayerCount"]
                var imgName = ""
                if (cbBankerCount > cbPlayerCount) {
                    imgName = "lhd_32"
                    BankWinNum++
                } else if (cbBankerCount < cbPlayerCount) {
                    imgName = "lhd_33"
                    PlayerWinNum++
                } else if (cbBankerCount == cbPlayerCount) {
                    imgName = "lhd_zhupan_he"
                    HeWinNum++
                }
                let img = betImgPool.getFreeObject(imgName)
                img.width = 18;
                img.height = 18;
                img["x"] = 1.5 + (Math.floor(i / 6)) * 21;
                img["y"] = 1.5 + (Math.floor(i % 6)) * 21;
                this.playPanel[LuName].addChild(img);
                if (i == (leng - 1)) {
                    this.playPanel.longNum.text = String(PlayerWinNum)
                    this.playPanel.huNum.text = String(BankWinNum)
                    this.playPanel.heNum.text = String(HeWinNum)
                    this.playPanel.zongNum.text = String(leng)
                    if (ifLast) {
                        EffectUtils.Twinkle(img)
                    }
                }

                //全路结束

                var type = null;
                if (cbBankerCount > cbPlayerCount) {
                    type = 0
                } else if (cbBankerCount < cbPlayerCount) {
                    type = 1
                } else if (cbBankerCount == cbPlayerCount) {
                    type = 2
                }
                if (type != 2) {//和局不换位置 不记录
                    if (upType != null) {//前面没记录就不换位置，但是当前不是和局要记录
                        if (type == upType) {//向下换行
                            hang++;
                            if (hang > maxHang) {//超出最大行要向右换列
                                hang = maxHang
                                lie++
                            }
                            if (find(lie, hang)) {//该行已被占位要向右换列
                                maxHang = hang - 1;
                                hang = maxHang
                                lie++
                            }
                        } else {//向右换列 不能使用现有的列,因为行不足6的时候列会向右延申。应该读取数组 ，哪一行第0个是空就是用该位置的列
                            hang = 0
                            maxHang = 5;//因图片变化导致向右换列，最大行恢复为6
                            //找到下一列,
                            for (let b = 0; b < List.length; b++) {
                                if (find(b, 0)) {
                                    lie = b + 1
                                } else {
                                    break
                                }
                            }
                        }
                    }
                    upType = type;
                }
                //行列决定后生成该位置的数据
                var obj = getObj(lie, hang)
                if (type == 0) {
                    obj["zhuang"] = 1
                }
                if (type == 1) {
                    obj["xian"] = 1
                }
                if (type == 2) {
                    obj["he"] += 1
                }
                if ((i == (leng - 1)) && ifLast) {
                    obj["isLast"] = true;
                }
            }

            //最后根据红蓝分离的二维数组生成视图
            if (List.length > dlieshu) {
                List = List.slice(-dlieshu)
            }
            for (let i = 0; i < List.length; i++) {
                let List2: Array<Object> = List[i]
                for (let j = 0; j < List2.length; j++) {
                    let obj = List2[j]
                    if (obj != null) {
                        if (obj["zhuang"] == 1) {
                            let img = betImgPool.getFreeObject("lhd_h")
                            img.width = 18;
                            img.height = 18;
                            img.x = i * 21 + 1.5;
                            img.y = j * 21 + 1.5;
                            this.playPanel[dLuName].addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                        if (obj["xian"] == 1) {
                            let img = betImgPool.getFreeObject("lhd_lan")
                            img.width = 18;
                            img.height = 18;
                            img.x = i * 21 + 1.5;
                            img.y = j * 21 + 1.5;
                            this.playPanel[dLuName].addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                        if (obj["he"] > 0) {
                            let text = new eui.Label(obj["he"] + "")
                            text.x = i * 21 + 4.5;
                            text.y = j * 21 + 4.5;
                            text.size = 18
                            text.textColor = 0x67BC0B
                            this.playPanel[dLuName].addChild(text)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(text)
                            }
                        }
                    }
                }
            }


            // //路单是否滚动
            // if (Math.ceil(LhdVO.getVo().zhupanlu.length / 6) > 8) {
            //     thisBack.playPanel.quanlu_zhupanlu_scoll_group.x = thisBack.playPanel.quanlu_zhupanlu_scoll_group.x - (Math.ceil(LhdVO.getVo().zhupanlu.length / 6) - 8) * 21
            // }
            // for (let i = 0; i < LhdVO.getVo().zhupanlu.length; i++) {
            //     let img = new eui.Image();
            //     img.source = LhdVO.getVo().zhupanlu[i]["res"];
            //     img.x = LhdVO.getVo().zhupanlu[i]["x"];
            //     img.y = LhdVO.getVo().zhupanlu[i]["y"];
            //     img.width = 18;
            //     img.height = 18;
            //     thisBack.playPanel.quanlu_zhupanlu_scoll_group.addChild(img)
            // }
            //最后根据数组生成视图
            // this.showDalu(LhdVO.getVo().dalu, "dalu_group")
        }

        private honglanList: Array<Array<number>> = [];//红蓝混合不包含“和”的数组，用来生成 大眼仔 小路 和甲由路,省去小路和甲由路生成这个数组的工作量
        //大眼仔路 
        //ludan 路单数据，显示视图时使用VO中的实时路单数据，问路时传入新增过庄赢或者闲赢模拟的路单数据 
        //wenlu 是否问路调用。计算庄问路时服用此方法但不用刷新视图，而是返回计算后的数组
        private showDaYanZai(ifLast: false = false, wenlu: boolean = false) {
            var ludan = LhdVO.getVo().ludan
            var leng = ludan.length
            var list: Array<Array<number>> = [[]];
            var hang = 0//竖坐标
            var lie = 0//横坐标
            var upType = null//上一次是什么 0庄 1闲 2和
            //生成大眼仔视图 根据大路,但是超出6个还是不拐弯
            for (let i = 0; i <= leng - 1; i++) {
                var data = ludan[i];
                var cbBankerCount = data["cbBankerCount"]
                var cbPlayerCount = data["cbPlayerCount"]
                var type = null;
                if (cbBankerCount > cbPlayerCount) {
                    type = 0
                } else if (cbBankerCount < cbPlayerCount) {
                    type = 1
                } else if (cbBankerCount == cbPlayerCount) {
                    type = 2
                }
                if (type != 2) {//和局不换位置 不记录
                    if (upType != null) {//前面没记录就不换位置，但是当前不是和局要记录
                        if (type == upType) {//向下换行
                            hang++;
                        } else {//向右换列
                            hang = 0
                            lie++
                        }
                    }
                    upType = type;
                }
                //行列决定后生成该位置的数据占位
                if (list[lie] == null) {
                    list[lie] = [];
                }
                if (list[lie][hang] == null) {
                    list[lie][hang] = 1;
                }
            }
            this.honglanList = list;

            //根据上面生成的大路来生成大眼仔
            if (list.length < 2) {
                return;
            }
            if (list.length == 2 && list[1].length < 2) {
                return;
            }
            //先按大路红蓝色生成 红蓝共存的数组。再迭代数组生成纵横红蓝分离的视图
            var lie = 1;
            var hang = 1;
            var findIsNull = function (arr: Array<Array<Object>>, x, y) {
                if (arr.length > x) {
                    if (arr[x].length > y) {
                        return true;
                    }
                }
                return false;
            }
            var colorList = [];
            for (let i = lie; i < list.length; i++) {
                for (let k = hang; k < list[i].length; k++) {
                    var x = i;
                    var y = k;
                    var color = null;//0红1蓝
                    var change = false
                    if (k == 0) {//当前行列在列首时将当前行列移动到前列列尾,并且最终颜色要取反
                        x = i - 1
                        y = list[x].length
                        change = true
                    }
                    if (findIsNull(list, x - 1, y) && findIsNull(list, x - 1, y - 1)) { //连连拍
                        color = 0
                    }
                    if (!findIsNull(list, x - 1, y) && !findIsNull(list, x - 1, y - 1)) { //长庄/长闲
                        color = 0
                    }
                    if (!findIsNull(list, x - 1, y) && findIsNull(list, x - 1, y - 1)) { //两房1厅
                        color = 1
                    }
                    if (change) {
                        if (color == 0) {
                            color = 1;
                        } else {
                            color = 0;
                        }
                    }
                    colorList.push(color)
                }
                hang = 0;
            }
            //根据上面得到的红蓝混合数组生成红蓝分离的二维数组
            var arr: Array<Array<Object>> = []
            var hang = 0//竖坐标
            var lie = 0//横坐标
            var maxHang = 5;//1列最多6行，若第2列的第6行被第1列向右延申占领了，第2列就只能最大5行
            var upType = null//上一次是什么 0红 1蓝

            var getObj = function (lie, hang): Object {  //从数组指定位置获取对象，没有就创建
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return arr[lie][hang]
                    }
                }
                if (arr[lie] == null) {
                    arr[lie] = [];
                }
                if (arr[lie][hang] == null) {
                    arr[lie][hang] = {
                        color: null
                    }
                }
                return arr[lie][hang]
            }
            var find = function (lie, hang): Boolean {
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return true
                    }
                }
                return false;
            }
            for (let i = 0; i < colorList.length; i++) {
                var type = colorList[i];
                if (type == 0) {
                    type = 0
                } else {
                    type = 1
                }
                if (upType != null) {//前面没记录就不换位置，但是当前不是和局要记录
                    if (type == upType) {//向下换行
                        hang++;
                        if (hang > maxHang) {//超出最大行要向右换列
                            hang = maxHang
                            lie++
                        }
                        if (find(lie, hang)) {//该行已被占位要向右换列
                            maxHang = hang - 1;
                            hang = maxHang
                            lie++
                        }
                    } else {//向右换列 不能使用现有的列,因为行不足6的时候列会向右延申。应该读取数组 ，哪一行第0个是空就是用该位置的列
                        hang = 0
                        maxHang = 5;//因图片变化导致向右换列，最大行恢复为6
                        //找到下一列,
                        for (let b = 0; b < arr.length; b++) {
                            if (find(b, 0)) {
                                lie = b + 1
                            } else {
                                break
                            }
                        }
                    }
                }
                upType = type;
                //行列决定后生成该位置的数据
                var obj = getObj(lie, hang)
                obj["color"] = type
                if (ifLast && i == (colorList.length - 1)) {
                    obj["isLast"] = true;
                }
            }
            if (wenlu) {//问路不更新视图，直接返回最后得出的数组
                return arr
            }
            //最后根据红蓝分离的二维数组生成视图
            if (arr.length > 16) {
                arr = arr.slice(-16)
            }
            //最后根据数组生成视图
            for (let i = 0; i < this.playPanel.quanlu_dayanzai_scoll_group.numChildren; i++) {
                if (this.playPanel.quanlu_dayanzai_scoll_group.getChildAt(i) instanceof eui.Image) {
                    betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_dayanzai_scoll_group.getChildAt(i))
                }
            }
            this.playPanel.quanlu_dayanzai_scoll_group.removeChildren();
            for (let i = 0; i < arr.length; i++) {
                let List2: Array<Object> = arr[i]
                for (let j = 0; j < List2.length; j++) {
                    let obj = List2[j]
                    if (obj != null) {
                        if (obj["color"] == 0) {
                            let img = betImgPool.getFreeObject("lhd_h")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_dayanzai_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                        if (obj["color"] == 1) {
                            let img = betImgPool.getFreeObject("lhd_lan")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_dayanzai_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                    }
                }
            }
        }
        //小路
        private showXiaoLu(ifLast: boolean = false, wenlu: boolean = false) {
            //根据上面生成的大路来生成小路，规则跟大眼仔类似。不过大眼仔是与前一排比较，小路是于前2牌比叫。牌头前移还是只移一行
            var list = this.honglanList;
            if (list.length < 3) {
                return;
            }
            if (list.length == 3 && list[2].length < 2) {
                return;
            }
            //先按大路红蓝色生成 红蓝共存的数组。再迭代数组生成纵横红蓝分离的视图
            var lie = 2;
            var hang = 1;
            var findIsNull = function (arr: Array<Array<Object>>, x, y) {
                if (arr.length > x) {
                    if (arr[x].length > y) {
                        return true;
                    }
                }
                return false;
            }
            var colorList = [];
            for (let i = lie; i < list.length; i++) {
                for (let k = hang; k < list[i].length; k++) {
                    var x = i;
                    var y = k;
                    var color = null;//0红1蓝
                    var change = false
                    if (k == 0) {//当前行列在列首时将当前行列移动到前列列尾,并且最终颜色要取反
                        x = i - 1
                        y = list[x].length
                        change = true
                    }
                    if (findIsNull(list, x - 2, y) && findIsNull(list, x - 2, y - 1)) { //连连拍
                        color = 0
                    }
                    if (!findIsNull(list, x - 2, y) && !findIsNull(list, x - 2, y - 1)) { //长庄/长闲
                        color = 0
                    }
                    if (!findIsNull(list, x - 2, y) && findIsNull(list, x - 2, y - 1)) { //两房1厅
                        color = 1
                    }
                    if (change) {
                        if (color == 0) {
                            color = 1;
                        } else {
                            color = 0;
                        }
                    }
                    colorList.push(color)
                }
                hang = 0;
            }
            //根据上面得到的红蓝混合数组生成红蓝分离的二维数组
            var arr: Array<Array<Object>> = []
            var hang = 0//竖坐标
            var lie = 0//横坐标
            var maxHang = 5;//1列最多6行，若第2列的第6行被第1列向右延申占领了，第2列就只能最大5行
            var upType = null//上一次是什么 0红 1蓝

            var getObj = function (lie, hang): Object {  //从数组指定位置获取对象，没有就创建
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return arr[lie][hang]
                    }
                }
                if (arr[lie] == null) {
                    arr[lie] = [];
                }
                if (arr[lie][hang] == null) {
                    arr[lie][hang] = {
                        color: null
                    }
                }
                return arr[lie][hang]
            }
            var find = function (lie, hang): Boolean {
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return true
                    }
                }
                return false;
            }
            for (let i = 0; i < colorList.length; i++) {
                var color = colorList[i];
                if (upType != null) {//前面没记录就不换位置
                    if (color == upType) {//向下换行
                        hang++;
                        if (hang > maxHang) {//超出最大行要向右换列
                            hang = maxHang
                            lie++
                        }
                        if (find(lie, hang)) {//该行已被占位要向右换列
                            maxHang = hang - 1;
                            hang = maxHang
                            lie++
                        }
                    } else {//向右换列 不能使用现有的列,因为行不足6的时候列会向右延申。应该读取数组 ，哪一行第0个是空就是用该位置的列
                        hang = 0
                        maxHang = 5;//因图片变化导致向右换列，最大行恢复为6
                        //找到下一列,
                        for (let b = 0; b < arr.length; b++) {
                            if (find(b, 0)) {
                                lie = b + 1
                            } else {
                                break
                            }
                        }
                    }
                }
                upType = color;
                //行列决定后生成该位置的数据
                var obj = getObj(lie, hang)
                obj["color"] = color
                if (ifLast && (i == colorList.length - 1)) {
                    obj["isLast"] = true;
                }

            }
            if (wenlu) {//问路不更新视图，直接返回最后得出的数组
                return arr
            }
            //最后根据红蓝分离的二维数组生成视图
            if (arr.length > 16) {
                arr = arr.slice(-16)
            }
            for (let i = 0; i < this.playPanel.quanlu_xiaolu_scoll_group.numChildren; i++) {
                if (this.playPanel.quanlu_xiaolu_scoll_group.getChildAt(i) instanceof eui.Image) {
                    betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_xiaolu_scoll_group.getChildAt(i))
                }
            }
            this.playPanel.quanlu_xiaolu_scoll_group.removeChildren();
            for (let i = 0; i < arr.length; i++) {
                let List2: Array<Object> = arr[i]
                for (let j = 0; j < List2.length; j++) {
                    let obj = List2[j]
                    if (obj != null) {
                        if (obj["color"] == 0) {
                            let img = betImgPool.getFreeObject("lhd_xh")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_xiaolu_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                        if (obj["color"] == 1) {
                            let img = betImgPool.getFreeObject("lhd_xb")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_xiaolu_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                    }
                }
            }
        }
        //甲由路
        private showJiaYouLu(ifLast: boolean = false, wenlu: boolean = false) {
            //根据上面生成的大路来生成小路，规则跟大眼仔类似。不过大眼仔是与前一排比较，小路是于前2牌比叫。牌头前移还是只移一行
            var list = this.honglanList;
            if (list.length < 4) {
                return;
            }
            if (list.length == 4 && list[2].length < 2) {
                return;
            }
            //先按大路红蓝色生成 红蓝共存的数组。再迭代数组生成纵横红蓝分离的视图
            var lie = 3;
            var hang = 1;
            var findIsNull = function (arr: Array<Array<Object>>, x, y) {
                if (arr.length > x) {
                    if (arr[x].length > y) {
                        return true;
                    }
                }
                return false;
            }
            var colorList = [];
            for (let i = lie; i < list.length; i++) {
                for (let k = hang; k < list[i].length; k++) {
                    var x = i;
                    var y = k;
                    var color = null;//0红1蓝
                    var change = false
                    if (k == 0) {//当前行列在列首时将当前行列移动到前列列尾,并且最终颜色要取反
                        x = i - 1
                        y = list[x].length
                        change = true
                    }
                    if (findIsNull(list, x - 3, y) && findIsNull(list, x - 3, y - 1)) { //连连拍
                        color = 0
                    }
                    if (!findIsNull(list, x - 3, y) && !findIsNull(list, x - 3, y - 1)) { //长庄/长闲
                        color = 0
                    }
                    if (!findIsNull(list, x - 3, y) && findIsNull(list, x - 3, y - 1)) { //两房1厅
                        color = 1
                    }
                    if (change) {
                        if (color == 0) {
                            color = 1;
                        } else {
                            color = 0;
                        }
                    }
                    colorList.push(color)
                }
                hang = 0;
            }
            //根据上面得到的红蓝混合数组生成红蓝分离的二维数组
            var arr: Array<Array<Object>> = []
            var hang = 0//竖坐标
            var lie = 0//横坐标
            var maxHang = 5;//1列最多6行，若第2列的第6行被第1列向右延申占领了，第2列就只能最大5行
            var upType = null//上一次是什么 0红 1蓝

            var getObj = function (lie, hang): Object {  //从数组指定位置获取对象，没有就创建
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return arr[lie][hang]
                    }
                }
                if (arr[lie] == null) {
                    arr[lie] = [];
                }
                if (arr[lie][hang] == null) {
                    arr[lie][hang] = {
                        color: null
                    }
                }
                return arr[lie][hang]
            }
            var find = function (lie, hang): Boolean {
                if (arr[lie] != null) {
                    if (arr[lie][hang] != null) {
                        return true
                    }
                }
                return false;
            }
            for (let i = 0; i < colorList.length; i++) {
                var color = colorList[i];
                if (upType != null) {//前面没记录就不换位置
                    if (color == upType) {//向下换行
                        hang++;
                        if (hang > maxHang) {//超出最大行要向右换列
                            hang = maxHang
                            lie++
                        }
                        if (find(lie, hang)) {//该行已被占位要向右换列
                            maxHang = hang - 1;
                            hang = maxHang
                            lie++
                        }
                    } else {//向右换列 不能使用现有的列,因为行不足6的时候列会向右延申。应该读取数组 ，哪一行第0个是空就是用该位置的列
                        hang = 0
                        maxHang = 5;//因图片变化导致向右换列，最大行恢复为6
                        //找到下一列,
                        for (let b = 0; b < arr.length; b++) {
                            if (find(b, 0)) {
                                lie = b + 1
                            } else {
                                break
                            }
                        }
                    }
                }
                upType = color;
                //行列决定后生成该位置的数据
                var obj = getObj(lie, hang)
                obj["color"] = color
                if (ifLast && (i == colorList.length - 1)) {
                    obj["isLast"] = true;
                }
            }
            if (wenlu) {//问路不更新视图，直接返回最后得出的数组
                return arr
            }
            //最后根据红蓝分离的二维数组生成视图
            if (arr.length > 16) {
                arr = arr.slice(-16)
            }
            for (let i = 0; i < this.playPanel.quanlu_yueyou_scoll_group.numChildren; i++) {
                if (this.playPanel.quanlu_yueyou_scoll_group.getChildAt(i) instanceof eui.Image) {
                    betImgPool.returnObject(<eui.Image>this.playPanel.quanlu_yueyou_scoll_group.getChildAt(i))
                }
            }
            this.playPanel.quanlu_yueyou_scoll_group.removeChildren();
            for (let i = 0; i < arr.length; i++) {
                let List2: Array<Object> = arr[i]
                for (let j = 0; j < List2.length; j++) {
                    let obj = List2[j]
                    if (obj != null) {
                        if (obj["color"] == 0) {
                            let img = betImgPool.getFreeObject("lhd_yh")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_yueyou_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                        if (obj["color"] == 1) {
                            let img = betImgPool.getFreeObject("lhd_yl")
                            img.width = 9;
                            img.height = 9;
                            img.x = i * 10.5 + 0.75;
                            img.y = j * 10.5 + 0.75;
                            this.playPanel.quanlu_yueyou_scoll_group.addChild(img)
                            if (obj["isLast"]) {
                                EffectUtils.Twinkle(img)
                            }
                        }
                    }
                }
            }
        }
        //路单刷新
        private ludanreFlush() {
            var thisBack = this;
            let obj = {}
            if (LhdVO.getVo().result == 1) {
                obj["res"] = "lhd_33"
            }
            else if (LhdVO.getVo().result == 2) {
                obj["res"] = "lhd_32"
            }
            else if (LhdVO.getVo().result == 3) {
                obj["res"] = "lhd_zhupan_he"
            }
            let img = new eui.Image();
            img.width = 18;
            img.height = 18;
            img.source = obj["res"];
            if (LhdVO.getVo().zhupanlu.length % 6 && LhdVO.getVo().zhupanlu.length != 0) {
                obj["x"] = LhdVO.getVo().zhupanlu[LhdVO.getVo().zhupanlu.length - 1]["x"];
                obj["y"] = LhdVO.getVo().zhupanlu[LhdVO.getVo().zhupanlu.length - 1]["y"] + 21;
                img.x = obj["x"];
                img.y = obj["y"];
                thisBack.playPanel.quanlu_zhupanlu_scoll_group.addChild(img);
                EffectUtils.Twinkle(img);
                LhdVO.getVo().zhupanlu.push(obj);

            }
            //正好48个显示的时候往左移动
            else if (LhdVO.getVo().zhupanlu.length % 6 == 0) {
                if (LhdVO.getVo().zhupanlu.length >= 48) {
                    let newX = thisBack.playPanel.quanlu_zhupanlu_scoll_group.x - 21
                    egret.Tween.get(thisBack.playPanel.quanlu_zhupanlu_scoll_group).to({ x: newX }, 300).call(() => {
                        obj["x"] = LhdVO.getVo().zhupanlu[LhdVO.getVo().zhupanlu.length - 1]["x"] + 21;
                        obj["y"] = 1.5;
                        img.x = obj["x"];
                        img.y = obj["y"];
                        thisBack.playPanel.quanlu_zhupanlu_scoll_group.addChild(img);
                        EffectUtils.Twinkle(img);
                        LhdVO.getVo().zhupanlu.push(obj);

                    })
                }
                else {
                    obj["x"] = LhdVO.getVo().zhupanlu[LhdVO.getVo().zhupanlu.length - 1]["x"] + 21;
                    obj["y"] = 1.5;
                    img.x = obj["x"];
                    img.y = obj["y"];
                    thisBack.playPanel.quanlu_zhupanlu_scoll_group.addChild(img);
                    EffectUtils.Twinkle(img);
                    LhdVO.getVo().zhupanlu.push(obj);

                }

            }

        }
        //游戏结算
        private gameOver() {
            this.globLook = true;
            this.IsUserScore(0)
            var thisBack = this;
            thisBack.playPanel.timeOut.destroy()
            var timefirst = new Date().getTime()

            //停止下注动画
            this.playPanel.bet_button_bg_1.visible = false;
            this.playPanel.bet_button_bg_3.visible = false;
            this.playPanel.bet_button_bg_5.visible = false;
            var stopBet = () => {
                thisBack.playPanel.title.source = "wjl_tzxz"
                thisBack.playPanel.title.visible = true;
                egret.Tween.get(thisBack.playPanel.title).to({ x: GameConfig.curWidth() / 2 - thisBack.playPanel.title.width / 2 }, 232).wait(500).to({ x: GameConfig.curWidth() }, 232).call(() => {
                    thisBack.playPanel.title.visible = false;
                    thisBack.playPanel.title.x = -(this.playPanel.title.width);
                    thisBack.playPanel.xiazhu_tips.visible = false;
                    fapai();
                })
            }

            // var animationS = () => {
            //     thisBack.playPanel.xiazhu_tips.source = "lhd_xiuxi"
            //     thisBack.playPanel.xiazhu_tips.visible = true;
            //     thisBack.playPanel.timeOut.init(9, true)
            //     thisBack.playPanel.bet_button_bg_1.visible = false;
            //     thisBack.playPanel.bet_button_bg_3.visible = false;
            //     thisBack.playPanel.bet_button_bg_5.visible = false;
            //     this.playPanel.bipai_group.visible = false;
            //     this.playPanel.poker_group.visible = false;
            // }

            //比牌动画start
            var bipai = () => {
                thisBack.IsUserScore(LhdVO.getVo().lUserScore, false, true)
                thisBack.playPanel.xiazhu_tips.source = "lhd_kaipai"
                thisBack.playPanel.xiazhu_tips.visible = true;
                thisBack.playPanel.timeOut.init(4, true)
                thisBack.playPanel.bipai_left0.x = - thisBack.playPanel.bipai_left0.width
                thisBack.playPanel.bipai_right0.x = GameConfig.curWidth();
                this.playPanel.bipai_group.visible = true;
                egret.Tween.get(this.playPanel.bipai_left0).wait(400).to({ x: 81.81 }, 400)
                egret.Tween.get(this.playPanel.bipai_right0).wait(400).to({ x: 887.24 }, 400).call(() => {
                    fapai();
                })
            }


            //发牌报点
            var fapai = () => {
                thisBack.playPanel.xiazhu_tips.source = "lhd_kaipai"
                thisBack.playPanel.xiazhu_tips.visible = true;
                thisBack.playPanel.poker_group.visible = true;
                let xian_leng = LhdVO.getVo().poker_xian.length
                let zhuang_leng = LhdVO.getVo().poker_zhuang.length
                var xian_pokerObjArr = Poker_public.idChangeObject(LhdVO.getVo().poker_xian)
                var zhuang_pokerObjArr = Poker_public.idChangeObject(LhdVO.getVo().poker_zhuang)
                let num = xian_leng + zhuang_leng;

                //找出最后一张扑克，动画结束时这张扑克需要调用后续的事件
                let end_poker: eui.Image = null;
                if (num == 2) {
                    end_poker = thisBack.playPanel.poker_zhuang_0;
                }
                //翻闲家牌
                for (let i = 0; i < xian_leng; i++) {
                    let poker: eui.Image = thisBack.playPanel["poker_xian_" + i];
                    let source = Global.getPokerById(LhdVO.getVo().poker_xian[i]);
                    egret.Tween.get(poker).wait(i * 2500).to({ visible: true }).call(() => {
                        SoundManage.startYinxiaoLoad("lhd_send_poker_mp3");
                    }).to({ x: thisBack.pokerXY[0][i].x, y: thisBack.pokerXY[0][i].y, scaleX: 0.78, scaleY: 0.78, rotation: 0 }, 300).call((poker, source, num) => {
                        EffectUtils.xuanZuanHuanTu(poker, source)
                        thisBack.baodian(xian_pokerObjArr, num, 0)
                    }, this, [poker, source, i + 1])
                }
                //翻庄家牌
                for (let i = 0; i < zhuang_leng; i++) {
                    let poker: eui.Image = thisBack.playPanel["poker_zhuang_" + i];
                    let source = Global.getPokerById(LhdVO.getVo().poker_zhuang[i]);
                    egret.Tween.get(poker).wait(i * 2500 + 1500).to({ visible: true }).call(() => {
                        SoundManage.startYinxiaoLoad("lhd_send_poker_mp3");
                    }).to({ x: thisBack.pokerXY[1][i].x, y: thisBack.pokerXY[1][i].y, scaleX: 0.78, scaleY: 0.78, rotation: 0 }, 300).call((poker, source, num) => {
                        EffectUtils.xuanZuanHuanTu(poker, source, 300, winBetadds)
                        thisBack.baodian(zhuang_pokerObjArr, num, 1)
                    }, this, [poker, source, i + 1])
                }
            }
            let xianBetAddsArr: Array<number> = [];//闲家要收取的筹码区域
            //赢钱区域特效
            var winBetadds = () => {
                let winArr = [];
                var xian_pokerObjArr = Poker_public.idChangeObject(LhdVO.getVo().poker_xian)
                var zhuang_pokerObjArr = Poker_public.idChangeObject(LhdVO.getVo().poker_zhuang)
                let resultObj = {};
                resultObj["cbBankerCount"] = zhuang_pokerObjArr[0].value;
                resultObj["cbPlayerCount"] = xian_pokerObjArr[0].value;
                resultObj["cbPingWinner"] = 0;
                if (xian_pokerObjArr[0].value > zhuang_pokerObjArr[0].value) {//闲
                    winArr.push(thisBack.playPanel.bet_button_bg_3)
                    xianBetAddsArr.push(3)
                    thisBack.playPanel.win_img.source = "lhd_xiany"
                    SoundManage.startYinxiaoLoad("long_win_mp3");
                }
                if (xian_pokerObjArr[0].value < zhuang_pokerObjArr[0].value) {//庄
                    winArr.push(thisBack.playPanel.bet_button_bg_5)
                    xianBetAddsArr.push(5)
                    thisBack.playPanel.win_img.source = "lhd_zhuangy"
                    SoundManage.startYinxiaoLoad("hu_win_mp3");
                }
                if (xian_pokerObjArr[0].value == zhuang_pokerObjArr[0].value) {//和
                    resultObj["cbPingWinner"] = 1;
                    winArr.push(thisBack.playPanel.bet_button_bg_1)
                    xianBetAddsArr.push(1)
                    thisBack.playPanel.win_img.source = "lhd_hey"
                    SoundManage.startYinxiaoLoad("he_mp3");
                }
                LhdVO.getVo().ludan.push(resultObj);
                for (let i = 0; i < winArr.length; i++) {
                    EffectUtils.Twinkle(winArr[i]);
                    if (winArr.length - i == 1) {
                        thisBack.playPanel.xiazhu_tips.source = "lhd_paijiang"
                        thisBack.playPanel.xiazhu_tips.visible = true;
                        thisBack.playPanel.timeOut.init((LhdVO.getVo().cbTimeLeave - 4), true)
                        EffectUtils.Twinkle(winArr[i], 3, 200, shouChouMa_zhuang);
                    } else {
                        EffectUtils.Twinkle(winArr[i]);
                    }
                }
                let btnCode = 0;
                if (this.selectLudan == this.playPanel.dalu_button) {
                    btnCode = 1
                }
                if (this.selectLudan == this.playPanel.zhupan_button) {
                    btnCode = 2
                }
                thisBack.ludanShow(true, btnCode);
                EffectUtils.Twinkle(thisBack.playPanel.win_img)
            }
            //收筹码-庄
            var shouChouMa_zhuang = () => {
                for (let i = 0; i < thisBack.betImgArr.length; i++) {
                    if (xianBetAddsArr.indexOf(i) == -1) {
                        let imgArr: Array<eui.Image> = thisBack.betImgArr[i]
                        for (let j = 0; j < imgArr.length; j++) {
                            egret.Tween.get(imgArr[j]).to({ x: 617, y: 95 }, 300).call((img: eui.Image) => {
                                egret.Tween.removeTweens(img);
                                if (thisBack.playPanel.bet_img_group.contains(img)) {
                                    thisBack.playPanel.bet_img_group.removeChild(img);
                                    betImgPool.returnObject(img);
                                }
                            }, this, [imgArr[j]])
                            if (Math.random() * 100 < 5) {//筹码太多,声音随机次数播放,降低性能消耗
                                let t = egret.setTimeout(() => {
                                    SoundManage.startYinxiaoLoad("lhd_add_bet_mp3");
                                    egret.clearTimeout(t)
                                }, this, this.random_num(10, 800))
                            }
                        }
                    }
                }
                egret.setTimeout(peiChouMa, this, 800)
            }
            //赔筹码
            var peiChouMa = () => {
                let endX, endY, width, heigth, imgArr: Array<eui.Image>, peilv: number;//筹码飞行动画结束位置,结束区域宽高,装筹码的数组,赔率
                for (let i = 0; i < thisBack.betImgArr.length; i++) {
                    if (xianBetAddsArr.indexOf(i) != -1) {//此区域要赔钱
                        switch (i) {
                            case 3://龙
                                endX = 267
                                endY = 197
                                width = 288
                                heigth = 100
                                peilv = 11
                                break;
                            case 5://虎
                                endX = 795
                                endY = 197
                                width = 288
                                heigth = 100
                                peilv = 8
                                break;
                            case 1://和
                                endX = 287
                                endY = 395
                                width = 804
                                heigth = 80
                                peilv = 20
                                break;
                        }
                        imgArr = thisBack.betImgArr[i];
                        let num = imgArr.length;//查看该区域当前有多少个筹码
                        for (let j = 0; j < num; j++) {
                            for (let y = 0; y < peilv; y++) {//按照赔率和当前的已有筹码相同的图片生成新的筹码
                                var img = betImgPool.getFreeObject(imgArr[j].source + "");
                                img.x = 617;
                                img.y = 95;
                                img.width = 50;
                                img.height = 50;
                                img.name = imgArr[j].name;//记住是谁下的注，庄家赔钱时这个注要飞向下注那个玩家
                                this.playPanel.bet_img_group.addChild(img);
                                imgArr.push(img)
                                egret.Tween.get(img).wait(this.random_num(50, 700)).to({ x: endX + width * Math.random(), y: endY + heigth * Math.random() }, 500, egret.Ease.circInOut).call((img: eui.Image) => {
                                    egret.Tween.removeTweens(img);
                                }, this, [img]);
                            }
                            if (Math.random() * 100 < 5) {//筹码太多,声音随机次数播放,降低性能消耗
                                let t = egret.setTimeout(() => {
                                    SoundManage.startYinxiaoLoad("lhd_add_bet_mp3");
                                    egret.clearTimeout(t)
                                }, this, this.random_num(10, 800));
                            }
                        }
                    }
                }
                egret.setTimeout(shouChouMa_xian, this, 1200)

            }
            //收筹码-闲
            var shouChouMa_xian = () => {
                for (let i = 0; i < thisBack.betImgArr.length; i++) {
                    if (xianBetAddsArr.indexOf(i) != -1) {
                        let imgArr = thisBack.betImgArr[i];
                        for (let i = 0; i < imgArr.length; i++) {
                            var x = this.playPanel.otherUserImg.x + 40 - this.playPanel.bet_img_group.x
                            var y = this.playPanel.otherUserImg.y + 30 - this.playPanel.bet_img_group.y
                            if (imgArr[i].name == LhdVO.getVo().wChairId + "") {
                                x = this.playPanel.userInfo.x + 60 - this.playPanel.bet_img_group.x
                                y = this.playPanel.userInfo.y - 25 - this.playPanel.bet_img_group.y
                            }
                            egret.Tween.get(imgArr[i]).wait(this.random_num(50, 700)).to({ x: x, y: y }, 500, egret.Ease.backInOut).call((img: eui.Image) => {
                                egret.Tween.removeTweens(img);
                                if (thisBack.playPanel.bet_img_group.contains(img)) {
                                    thisBack.playPanel.bet_img_group.removeChild(img);
                                    betImgPool.returnObject(img)

                                }
                            }, this, [imgArr[i]]);
                            if (Math.random() * 100 < 5) {//筹码太多,声音随机次数播放,降低性能消耗
                                let t = egret.setTimeout(() => {
                                    SoundManage.startYinxiaoLoad("lhd_add_bet_mp3");
                                    egret.clearTimeout(t)
                                }, this, this.random_num(10, 800))
                            }
                        }
                    }
                }

                thisBack.playPanel.score_user.text = Global.getmeishufen(LhdVO.getVo().score_my / 100)
                egret.setTimeout(goldRef, this, 300)
                thisBack.playPanel.score_user.visible = true
                EffectUtils.flyObj(thisBack.playPanel.score_user)
                LhdVO.getVo().game_state = 0
            }
            var goldRef = () => {
                thisBack.playPanel.userMoney.text = (LhdVO.getVo().lUserScore + LhdVO.getVo().myBetNumAdds_1 + LhdVO.getVo().myBetNumAdds_3 + LhdVO.getVo().myBetNumAdds_5 + LhdVO.getVo().score_my) / 100 + ''
                this.globLook = false;
            }

            stopBet();

        }

        //推送场外玩家
        private receiveUserList() {
            if (LhdVO.getVo().structUserList) {
                this.playPanel.otherUserNum.text = LhdVO.getVo().structUserList.length + ""
            }
        }
        //中途加入 游戏状态
        private dataRecovery() {
            var thisBack = this;
            this.initRoomInfo();
            this.playPanel.bet_button_bg_1.visible = true;
            this.playPanel.bet_button_bg_3.visible = true;
            this.playPanel.bet_button_bg_5.visible = true;
            var goldArr = [
                LhdVO.getVo().betNumAdds_1,
                LhdVO.getVo().betNumAdds_3,
                LhdVO.getVo().betNumAdds_5
            ]
            let startX, startY, endX, endY, width, heigth, arr: Array<eui.Image>;//筹码飞行动画起始位置，结束位置,结束区域宽高,装筹码的数组
            for (var i in goldArr) {
                if (Number(i) === 2) {
                    endX = 287
                    endY = 395
                    width = 804
                    heigth = 80
                    arr = this.betImgArr[1];
                }
                else if (Number(i) === 0) {
                    endX = 267
                    endY = 197
                    width = 288
                    heigth = 100
                    arr = this.betImgArr[3];
                }
                else if (Number(i) === 1) {
                    endX = 795
                    endY = 197
                    width = 288
                    heigth = 100
                    arr = this.betImgArr[5];
                }
                // var imgArr = this.betImgArr[i];
                let betArr = this.qiegeJinbi(goldArr[i]);
                for (let y in betArr) {
                    let img = betImgPool.getFreeObject("bet_" + (betArr[y] / 100));
                    img.x = endX + width * Math.random()
                    img.y = endY + heigth * Math.random()
                    img.width = 50;
                    img.height = 50;
                    this.playPanel.bet_img_group.addChild(img);
                    arr.push(img)
                }
            }

            thisBack.playPanel.xiazhu_tips.source = "lhd_xiazhu"
            this.playPanel.timeOut.init(LhdVO.getVo().cbTimeLeave)
            this.IsUserScore(LhdVO.getVo().lUserScore, false, true)
        }

        //点击筹码组，为处于下注状态给出提示
        private betGroupClick() {
            if (this.playPanel.xiazhu_tips.source != "lhd_xiazhu") {
                EffectUtils.textFadeAway("非下注状态，请等待...")
            }
        }
        //选择筹码
        private onChipClick(event: egret.TouchEvent): void {
            for (var i = 0; i < 5; i++) {
                if (this.playPanel["bet_" + i] != event.currentTarget) {
                    this.playPanel["bet_" + i].name = '';
                    egret.Tween.removeTweens(this.playPanel["bet_" + i + "_bg"])
                    this.playPanel["bet_" + i + "_bg"].visible = false;
                    this.playPanel["bet_" + i + "_bg"].rotation = 0;
                } else {
                    if (event.currentTarget.name != 'ok') {
                        event.currentTarget.name = 'ok';
                        this.playPanel["bet_" + i + "_bg"].rotation = 0;
                        this.playPanel["bet_" + i + "_bg"].visible = true;
                        EffectUtils.rotationEffect(this.playPanel["bet_" + i + "_bg"])
                        EffectUtils.playDim(event.currentTarget)
                        this.selectBet = event.currentTarget;
                    }
                }
            }
        }
        //点击桌面下注
        private onRectClick(event: egret.TouchEvent): void {
            let betArea;
            if (event.currentTarget == this.playPanel.bet_button_bg_1) {
                betArea = 2
            }
            if (event.currentTarget == this.playPanel.bet_button_bg_3) {
                betArea = 0
            }
            if (event.currentTarget == this.playPanel.bet_button_bg_5) {
                betArea = 1
            }

            let imgNum;
            for (var i = 0; i < 5; i++) {
                if (this.playPanel["bet_" + i].name == 'ok') {
                    imgNum = this.bet_chip[i];
                    break;
                }
            }
            if (!imgNum) {
                return;
            }
            if (event.currentTarget) {
                egret.Tween.get(event.currentTarget).to({ visible: false }).wait(100).to({ visible: true })
            }
            if (LhdVO.getVo().lUserScore < 5000) {
                EffectUtils.textFadeAway("50 以上的余额才能下注!");
                this.IsUserScore(0)
                return;
            }
            if (LhdVO.getVo().lUserScore < imgNum) {
                EffectUtils.textFadeAway("金币不足!");
                return;
            }
            // LhdVO.getVo().lUserScore -= imgNum
            // this.betReceive()
            let obj = {
                cbBetArea: betArea,
                lBetScore: imgNum
            }
            SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.LHD, RegDataLhd.CMD_GP_UserAddScore, obj, false);
        }
        /**
         * 更改筹.码按钮状态
         * num:手头金额
         * xiazhu：是否下注后重置
         * startXiazhu：是否开局重置
         */
        private selectBet: eui.Button = null;
        public IsUserScore(num: number, xiazhu: boolean = false, startXiazhu: boolean = false) {
            var bet4 = Number(this.playPanel.bet_4.label) * 100
            var bet3 = Number(this.playPanel.bet_3.label) * 100
            var bet2 = Number(this.playPanel.bet_2.label) * 100
            var bet1 = Number(this.playPanel.bet_1.label) * 100
            var bet0 = Number(this.playPanel.bet_0.label) * 100
            //找出上次选中的筹码，若本轮金币不足导致筹码被取消选择，则筹码自动选择更低的
            let img = null;
            let modify = false;
            for (var i = 0; i < 5; i++) {
                if (this.playPanel['bet_' + i].name == 'ok') {
                    img = this.playPanel['bet_' + i];
                    break;
                }
            }
            if (num < bet4) {
                this.playPanel.bet_4.enabled = false
                this.playPanel.bet_4.name = ""
                this.playPanel.bet_4.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_4_bg.visible = false;
                this.playPanel.bet_4_bg.rotation = 0;
                egret.Tween.get(this.playPanel.bet_4_bg)
                if (img == this.playPanel.bet_4) {
                    modify = true;
                }
            } else {
                this.playPanel.bet_4.enabled = true
                this.playPanel.bet_4.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_4.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
            }
            if (num < bet3) {
                this.playPanel.bet_3.enabled = false
                this.playPanel.bet_3.name = ""
                this.playPanel.bet_3.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_3.name = '';
                this.playPanel.bet_3_bg.visible = false;
                this.playPanel.bet_3_bg.rotation = 0;
                egret.Tween.get(this.playPanel.bet_3_bg)
                if (img == this.playPanel.bet_3) {
                    modify = true;
                }
            } else {
                this.playPanel.bet_3.enabled = true
                this.playPanel.bet_3.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_3.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
            }
            if (num < bet2) {
                this.playPanel.bet_2.enabled = false
                this.playPanel.bet_2.name = ""
                this.playPanel.bet_2.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_2.name = '';
                this.playPanel.bet_2_bg.visible = false;
                this.playPanel.bet_2_bg.rotation = 0;
                egret.Tween.get(this.playPanel.bet_2_bg)
                if (img == this.playPanel.bet_2) {
                    modify = true;
                }
            } else {
                this.playPanel.bet_2.enabled = true
                this.playPanel.bet_2.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
            }
            if (num < bet1) {
                this.playPanel.bet_1.enabled = false
                this.playPanel.bet_1.name = ""
                this.playPanel.bet_1.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_1.name = '';
                this.playPanel.bet_1_bg.visible = false;
                this.playPanel.bet_1_bg.rotation = 0;
                egret.Tween.get(this.playPanel.bet_1_bg)
                if (img == this.playPanel.bet_1) {
                    modify = true;
                }
            } else {
                this.playPanel.bet_1.enabled = true
                this.playPanel.bet_1.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
            }
            if (num < bet0) {
                this.playPanel.bet_0.enabled = false
                this.playPanel.bet_0.name = ""
                this.playPanel.bet_0.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_0.name = '';
                this.playPanel.bet_0_bg.visible = false;
                this.playPanel.bet_0_bg.rotation = 0;
                egret.Tween.get(this.playPanel.bet_0_bg)
                if (img == this.playPanel.bet_0) {
                    modify = true;
                }
            } else {
                this.playPanel.bet_0.enabled = true
                this.playPanel.bet_0.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
                this.playPanel.bet_0.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onChipClick, this);
            }
            //因下注导致钱不够筹码更换
            if ((xiazhu && modify)) {
                if (num >= bet4) {
                    this.playPanel.bet_4.name = "ok";
                    this.playPanel.bet_4_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_4_bg);
                    this.selectBet = this.playPanel.bet_4;
                } else if (num >= bet3) {
                    this.playPanel.bet_3.name = "ok";
                    this.playPanel.bet_3_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_3_bg);
                    this.selectBet = this.playPanel.bet_3;
                } else if (num >= bet2) {
                    this.playPanel.bet_2.name = "ok";
                    this.playPanel.bet_2_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_2_bg);
                    this.selectBet = this.playPanel.bet_2;
                } else if (num >= bet1) {
                    this.playPanel.bet_1.name = "ok";
                    this.playPanel.bet_1_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_1_bg);
                    this.selectBet = this.playPanel.bet_1;
                } else if (num >= bet0) {
                    this.playPanel.bet_0.name = "ok";
                    this.playPanel.bet_0_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_0_bg);
                    this.selectBet = this.playPanel.bet_0;
                }
                if (num < 100) {
                    EffectUtils.textFadeAway("金币不足，无法下注");
                } else {
                    EffectUtils.textFadeAway("金币不足，已自动切换筹码");
                }
            }
            //新开局时上一局最后选中的筹码如果这一局依然可用则自动选中
            if (startXiazhu && this.selectBet != null) {
                if (num >= bet4 && this.selectBet == this.playPanel.bet_4) {
                    this.playPanel.bet_4.name = "ok"
                    this.playPanel.bet_4_bg.rotation = 0;
                    this.playPanel.bet_4_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_4_bg)
                }
                if (num >= bet3 && this.selectBet == this.playPanel.bet_3) {
                    this.playPanel.bet_3.name = "ok"
                    this.playPanel.bet_3_bg.rotation = 0;
                    this.playPanel.bet_3_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_3_bg)
                }
                if (num >= bet2 && this.selectBet == this.playPanel.bet_2) {
                    this.playPanel.bet_2.name = "ok"
                    this.playPanel.bet_2_bg.rotation = 0;
                    this.playPanel.bet_2_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_2_bg)
                }
                if (num >= bet1 && this.selectBet == this.playPanel.bet_1) {
                    this.playPanel.bet_1.name = "ok"
                    this.playPanel.bet_1_bg.rotation = 0;
                    this.playPanel.bet_1_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_1_bg)
                }
                if (num >= bet0 && this.selectBet == this.playPanel.bet_0) {
                    this.playPanel.bet_0.name = "ok"
                    this.playPanel.bet_0_bg.rotation = 0;
                    this.playPanel.bet_0_bg.visible = true;
                    EffectUtils.rotationEffect(this.playPanel.bet_0_bg)
                }
            }
        }
        //金币拆分
        private qiegeJinbi(fen: number): Array<any> {
            let Fen = fen
            let imgList: Array<any> = [];
            let guigeList = this.bet_chip;
            for (let j = guigeList.length; j >= 0; j--) {
                let len = Math.floor(Fen / guigeList[j]);
                if (len != 0) {
                    for (var k = 0; k < len; k++) {
                        imgList.push(guigeList[j]);
                        Fen -= guigeList[j];
                    }
                }
            }
            return imgList
        }
        //生成指定的随机数
        private random_num(min: number, max: number) {
            let Range = max - min;
            let Rand = Math.random();
            return (min + Math.round(Rand * Range));
        }
        //发牌报点
        //num已翻几张牌
        //adds 0闲家 1庄家
        private baodian(pokerObjArr: Array<Poker_public>, num, adds) {
            var dian = 0;
            for (var i = 0; i < num; i++) {
                var poker = pokerObjArr[i]
                dian += poker.value
            }
            var str = String(dian)
            SoundManage.startYinxiaoLoad("lhb_p_" + str + "_mp3");
        }
        //点击下拉菜单
        private menu_click() {
            if (this.playPanel.menu_button.name == "on") {//收起菜单
                egret.Tween.removeTweens(this.playPanel.menu_button)
                egret.Tween.removeTweens(this.playPanel.menu_group)
                this.playPanel.menu_button.name = "off"
                egret.Tween.get(this.playPanel.menu_button).to({ rotation: 0 }, 300)
                egret.Tween.get(this.playPanel.menu_group).to({ x: -260 }, 300).call((menu_group: eui.Group) => {
                    menu_group.visible = false;
                }, this, [this.playPanel.menu_group])
            } else {                                      //弹出菜单
                egret.Tween.removeTweens(this.playPanel.menu_button)
                egret.Tween.removeTweens(this.playPanel.menu_group)
                this.playPanel.menu_button.name = "on"
                this.playPanel.menu_group.visible = true;
                egret.Tween.get(this.playPanel.menu_button).to({ rotation: 90 }, 300)
                egret.Tween.get(this.playPanel.menu_group).to({ x: 0 }, 300)
            }
        }
        //点击设置
        private setClick() {
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SETTING)
        }
        //点击帮助
        private helpClick() {
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_HELP_LHD)
        }
        //点击反馈
        private fankuiClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_FANKUI, InstructionsEnum.GAME_TYPE_NAME.LHD)
        }
        //点击记录
        private jiluClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            var obj = {
                gameType: InstructionsEnum.GAME_TYPE_NAME.LHD,
                roomType: InstructionsEnum.LEVEL_GAME
            }
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_JILU, JSON.stringify(obj))
        }
        //点击退出
        private exitClick() {
            SoundManage.startAnniuBtnLoad();
            this.menu_click();
            if (LhdVO.getVo().game_state == 2) {
                let obj = new Object();
                obj[InstructionsEnum.TEXT] = "请等待游戏结束后离开！";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            } else {
                let obj = new Object();
                obj[InstructionsEnum.CODE] = PanelNotify.LHD.CLOSE_PLAY_GAME;
                obj[InstructionsEnum.TEXT] = "确定要离开游戏吗？";
                game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_TIP, obj);
            }
        }
        //点击玩家列表
        private userListClic() {
            SoundManage.startAnniuBtnLoad();
            game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_USER_LIST, InstructionsEnum.GAME_TYPE_NAME.LHD)
        }
    }

}


